package com.tuanzi.loan.web.bean.statistics;

import com.tuanzi.loan.business.entity.family.RegisterRecommendActivity;
import com.tuanzi.loan.business.entity.statistics.ActivityChannelConfig;
import com.tuanzi.loan.business.service.family.ProductInfoService;
import com.tuanzi.loan.business.service.family.RegisterRecommendActivityService;
import com.tuanzi.loan.business.service.statistics.ActivityChannelConfigService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.statistics.UnionLoginStatRequest;
import com.tuanzi.loan.vo.response.family.ProductInfoSearchResponse;
import com.tuanzi.loan.vo.response.statistics.UnionLoginStatResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.statistics.UnionLoginStatLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.List;

@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class UnionLoginStatBean extends JSFListingBean<UnionLoginStatRequest, UnionLoginStatResponse> {

	private static final long serialVersionUID = -1853686142256852849L;

	@Autowired
	private RegisterRecommendActivityService registerRecommendActivityService;
	@Autowired
	private ActivityChannelConfigService activityChannelConfigService;
	@Autowired
	private ProductInfoService productInfoService;

	private List<RegisterRecommendActivity> registerRecommendActivities;
	private List<ActivityChannelConfig> activityChannelConfigs;
	private List<ProductInfoSearchResponse> unionProductInfos;

	@PostConstruct
	public void init() {
		initLazyDataModel();
		registerRecommendActivities = registerRecommendActivityService.findAll();
		activityChannelConfigs = activityChannelConfigService.findAll();
		unionProductInfos = productInfoService.listAllUnionProductInfos();
	}

	public void onRest(){
		init();
	}

	private void initLazyDataModel() {
		$ = new UnionLoginStatRequest();
		lazyDataModel = new UnionLoginStatLazyDataModel($);
	}

}
